﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Text;

/// <summary>
/// StaticBase 的摘要说明
/// </summary>
public abstract class StaticBase : IDisposable
{
    public StaticBase()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    /// <summary>
    /// 默认编码方式
    /// </summary>
    protected Encoding code = Encoding.GetEncoding("utf-8");
    /// <summary>
    /// 写入页面数据流
    /// </summary>
    protected StreamWriter sw = null;
    /// <summary>
    /// 读取页面数据流
    /// </summary>
    protected StreamReader sr = null;
    /// <summary>
    /// 生成的静态页面保存文件夹路径
    /// </summary>
    protected string SavePath = "/Default/";
    /// <summary>
    /// 模板页面的文件夹路径
    /// </summary>
    protected string PagePath = "/template/";
    public abstract bool Osucess { set; get; }
    public abstract string Errorstring { set; get; }
    /// <summary>
    /// 具体生成静态方法
    /// </summary>
    protected abstract bool WriteFile();

    /// <summary>
    /// 不同模块的文件名称
    /// </summary>
    protected Dictionary<FlagsFileName, string> FileName
    {
        get
        {
            return new Dictionary<FlagsFileName, string>
                {
                    {FlagsFileName.News,"news"},
                    {FlagsFileName.Products,"products"},
                    {FlagsFileName.Newsclass,"Newsclass"},
                    {FlagsFileName.Productclass,"Productclass"},
                    {FlagsFileName.Navigation,"navigation"},
                };
        }
    }
    public void Dispose()
    {
        sw.Dispose();
        sr.Dispose();
    }

}
/// <summary>
/// 对应的页面名称
/// </summary>
public enum FlagsFileName : byte
{
    /// <summary>
    /// 新闻
    /// </summary>
    [Description("新闻")]
    News = 0,
    /// <summary>
    /// 产品
    /// </summary>
    [Description("产品")]
    Products = 1,
    [Description("新闻分类")]
    Newsclass = 2,
    [Description("产品分类")]
    Productclass = 3,
    [Description("导航")]
    Navigation = 4,
}